﻿using System;
using System.Collections.Generic;
using SobrietyEngine.Components;
using SobrietyEngine.Components.Common;
using SobrietyEngine.Components.Camera;
using SobrietyEngine.Components.Controller;
using Microsoft.Xna.Framework;
using SobrietyEngine.Scene;
using SobrietyEngine.Guids;
using Microsoft.Xna.Framework.Graphics;

namespace SobrietyEngine.Actor.Builders.Cameras
{
    public class FPSCameraBldr:BaseActorBuilder
    {
        public static IActor Build(IScene scene, Viewport fullscreen, GraphicsDevice graphicsDevice, CGuid owningPlayer, Vector3 worldUp, Vector3 worldRight, Vector3 worldForward)
        {
            //create 3D Scene camera
            //create a camera actor
            IActor actor = scene.CreateEmptyActor();

            Matrix viewScale = Matrix.Identity;
            Viewport view = new Viewport();
            view = fullscreen;
            view.Height = fullscreen.Height;
            view.Width = fullscreen.Width;
            viewScale = Matrix.CreateScale(1.0f, 1.0f, 1.0f);

            //lets have the camera start with its center on playerPos
            actor.AttachComponent(new PositionCmp(new Vector3(0, 0, 10)));
            IOrientation o = new OrientationCmp();
            o.SetWorldAxis(worldForward, worldUp, worldRight);
            actor.AttachComponent((IComponent)o);

            actor.AttachComponent(new Camera3DCmp(graphicsDevice, view, viewScale));
            actor.AttachComponent(new Cam3DFPS(owningPlayer));
            //lets have it follow our textured quad, above            
            //actor.AttachComponent(new SEGameExample.Components.Behavior.OrthoCamFollowActor(followActor, 3, new Vector3(0, 0.5f, 0)));

            actor.Initialize();
            return actor;
        }
    }
}
